﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using l1cs.server.model.Instance;
using l1cs.server.model;
using l1cs.server.templates;
using l1cs.server.datatables;

namespace l1cs.server.clientpackets
{
    public class C_TaxRate : ClientBasePacket
    {
        private const String _C_TAX_RATE = "[C] C_TaxRate";
        private static Logger _log = Logger.getLogger( typeof( C_TaxRate ).FullName );

        public C_TaxRate( byte[] abyte0, ClientThread clientthread )
            : base( abyte0 )
        {
            int i = readD();
            int j = readC();

            L1PcInstance player = clientthread.getActiveChar();
            if ( i == player.getId() )
            {
                L1Clan clan = L1World.getInstance().getClan( player.getClanname() );
                if ( clan != null )
                {
                    int castle_id = clan.getCastleId();
                    if ( castle_id != 0 )
                    { // 城主クラン
                        L1Castle l1castle = CastleTable.getInstance()
                                .getCastleTable( castle_id );
                        if ( j >= 10 && j <= 50 )
                        {
                            l1castle.setTaxRate( j );
                            CastleTable.getInstance().updateCastle( l1castle );
                        }
                    }
                }
            }
        }

        override
        public String getType()
        {
            return _C_TAX_RATE;
        }
    }
}